home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
lisp
/
kcl
/
akcl
/
akcl1615.lha
/
mp
/
mp_bfffo.c
< prev
next >
Wrap
Text File
|
1991-02-10
|
723b
|
34 lines
/*
double i; ulong x;
index of the first non zero bit numbering from left
Bit position measured from most significant end
to the first non zero bit of x
if (x == 2^i) bfffo(x) == (31 - truncate(i))
else if (x==0) 32
[truncate (i) chops off the decimal places]
bfffo(0) == 32
bfffo(1) == 31
bfffo(2) == 30
bfffo(3) == 30
bfffo(4) == 29
bfffo(5) == 29
..
*/
int bfffo(x)
unsigned long x;
{
int sc;
static int tabshi[16]={4,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0};
if(x&(0xffff0000)) sc=0;else {sc=16;x<<=16;}
if(!(x&(0xff000000))) {sc+=8;x<<=8;}
if(x&(0xf0000000)) x>>=28;else {sc+=4;x>>=24;}
sc+=tabshi[x];return sc;
}